package agents;

import game.constants.ReferenceAgent;
import game.constants.ReferenceSpecialFeature;
import interfaces.impl.Agent;
import objects.SpetialFeature;
import objects.WorldObject;
import universe.Universe;
import actions.ActionObjectFinish;
import constants.Constants;


public class AgentBuildFinish extends Agent{
	
	SpetialFeature life;
	SpetialFeature currentLife;
	
	ActionObjectFinish actionObjectFinish;

	@Override
	public void initializeActionList() {
		actionObjectFinish = new ActionObjectFinish();
		addAction(actionObjectFinish);
		
	}

	@Override
	public void initializeSpecialFeatures() {
		life= new SpetialFeature(ReferenceSpecialFeature.SPETIAL_FEATURE_LIFE);
		currentLife= new SpetialFeature(ReferenceSpecialFeature.SPETIAL_FEATURE_CURRENT_LIFE);
	
		
		addSpetialFeature(life);
		addSpetialFeature(currentLife);
	
		
		
	}

	@Override
	public void initializeName() {
		name="agent Build Finish";
		
	}

	@Override
	public void initializeId() {
		this.id=ReferenceAgent.AGENT_BUILD_FINISH;
		
	}

	@Override
	public void updateChild(WorldObject object, Universe universe, double time) {
		SpetialFeature isBuilding = object.getFeature(ReferenceSpecialFeature.SPETIAL_FEATURE_IS_BUILDING);
		if(isBuilding==null){
			System.out.println("isBui");
			return;
			}
		if(isBuilding.getValue()==Constants.FALSE){
			return;
		}
		if(currentLife.getValue()>=life.getValue()){
			
			ActionObjectFinish actionObjectFinish = new ActionObjectFinish();
			actionObjectFinish.setSource(object);
			actionObjectFinish.setTarget(object);
			universe.setAction(actionObjectFinish);
			System.out.println("TERMINE DE CONSTRUIR EL OBJETO");
			isActive=false;
		}
		
	}
	
	

}
